package cn.edu.scujcc;

import java.util.List;
import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class OrderService {
	@Autowired
	private OrderRepository repo;
	
	public List<Order> getAllOrder(){
		List<Order> result = null;
		result = repo.findAll();
		return result;
	}
	public boolean deleteOrder(String id) {
		boolean result =true;
		try {
			repo.deleteById(id);
		}catch (Exception c){
			result = false;
		}
		return result;
	}
	public Order getOrder(String id) {
		Order result = null;
		Optional<Order> op = repo.findById(id);
		if(op.isPresent()) {
			result = op.get();
		}
		return result;
	}
}
